package ca.unbc.cpsc672.fuzzy.rule;

import ca.unbc.cpsc672.fuzzy.IOUtils;
import ca.unbc.cpsc672.fuzzy.function.MembershipFunction;

public class IfFuzzyAnd implements IfClause {
	protected MembershipFunction ipt1;
	protected MembershipFunction ipt2;

	/**
	 * IF ipt1 AND ipt2
	 * 
	 * @param ipt1
	 * @param ipt2
	 * @param operator
	 */
	public IfFuzzyAnd(MembershipFunction ipt1, MembershipFunction ipt2) {
		this.ipt1 = ipt1;
		this.ipt2 = ipt2;
	}

	@Override
	public double getSupportLevel(double... iptx) {
		return FuzzyOperator.and(ipt1, ipt2, iptx[0], iptx[1]);
	}

	@Override
	public String toCSVString() {
		StringBuffer sb = new StringBuffer();
		sb.append(IOUtils.getTypeString(this)).append(",");
		sb.append(ipt1.getFullName()).append(",");
		sb.append(ipt2.getFullName()).append(",");
		return sb.toString();
	}

	@Override
	public MembershipFunction[] getMembershipFunctions() {
		return new MembershipFunction[] { ipt1, ipt2 };
	}

}
